

// UI.h

#ifndef _UI_h
#define _UI_h
#include "Button.h"
#include "arduino.h"
#include <Encoder.h>
#include <TFT_eSPI.h>
#include <lvgl.h>
#include <BleKeyboard.h>

class UI
{
private:
	TFT_eSPI tft = TFT_eSPI(); /* TFT instance */

	lv_obj_t *ta; // textarea 文本框
	lv_obj_t *roller; // roller for wpm
	lv_obj_t *rollMode; // roller for key type 
	lv_group_t *g;
	Button button = Button(35);

public:
	void init();
	void render_main();
	void disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p);
	void ui_loop();
	void fire_char(char c);
	bool encoder_read(lv_indev_drv_t *drv, lv_indev_data_t *data);
	void wpm_change_cb(lv_event_t *event);
	void key_change_cb(lv_event_t *event);
#if USE_LV_LOG != 0
	void ui_log(lv_log_level_t level, const char *file, uint32_t line, const char *dsc);
#endif
};

extern UI ui;

#endif
